//
//  LocationResultModel.m
//  o_amap
//
//  Created by Q神 on 2021/4/13.
//

#import "LocationResultModel.h"
#import "HQMapTools.h"

@interface LocationResultModel()

@property (nonatomic, strong) HQMapTools * mapTools;

@end

@implementation LocationResultModel

+ (LocationResultModel *)initWithLocation:(CLLocation *)location reGeocode:(AMapLocationReGeocode *)reGeocode {
    LocationResultModel *model = [[LocationResultModel alloc] init];
    
    if (location) { /// 得到定位信息，添加annotation

        /// 定位时间
        model.time = [[NSString stringWithFormat:@"%.0f", location.timestamp.timeIntervalSince1970] intValue];
        /// 定位精度
        model.accuracy = location.horizontalAccuracy;
        /// 纬度
        model.latitude = [NSNumber numberWithDouble:location.coordinate.latitude];
        /// 经度
        model.longitude = [NSNumber numberWithDouble:location.coordinate.longitude];
        /// 海拔高度
        model.altitude = [NSNumber numberWithDouble:location.altitude];
        /// 速度
        model.speed = [NSNumber numberWithDouble:location.speed];
        
        model.floor = [NSString stringWithFormat:@"%ld", (long)location.floor.level];
                
        /// 定位结果
        model.errorCode = 0;
        /// 定位错误信息
        model.errorInfo = @"location is success";
        
    } else {
        /// 定位结果错误码
        model.errorCode = 1;
        /// 定位错误信息
        model.errorInfo = @"location is fail";
    }

    if (reGeocode) {

        /// 国家
        model.country = [reGeocode country];
        /// 省份
        model.province = [reGeocode province];
        /// 城市
        model.city = [reGeocode city];
        /// 城市编码
        model.cityCode = [reGeocode citycode];
        /// 区县
        model.district = [reGeocode district];
        /// 街道
        model.street = [reGeocode street];
        /// 地址信息
        model.address = [reGeocode formattedAddress];
        /// 区域编码
        model.adCode = [reGeocode adcode];
        /// 兴趣点名称
        model.poiName = [reGeocode POIName];
        /// 所属兴趣点名称
        model.aoiName = [reGeocode AOIName];
        /// 门牌号
        model.streetNum = [reGeocode number];
    }
    
    return model;
}

@end


@implementation LocationQualityReport

@end
